let s = "Let's take LeetCode contest"
var reverseWords = function(s) {
    let start = 0
    let arr = Array.from(s)
    for(let i=0;i<arr.length;i++){
        if(arr[i]==" "){
            rever(arr,start,(i-1))
            start = i + 1
        }
        if(i==arr.length-1){
            rever(arr,start,i)
        }
    }
    return arr.join('')
};
function rever(arr,start,end){
    while(start<end){
        let mid = arr[start]
        arr[start] = arr[end]
        arr[end] = mid
        start++
        end--
    }
}
console.log(reverseWords(s));

